Power Series

Introduction

A power series is a series of the form (∑_(n=0)^∞)(Subscript[c, n])(x^n), where (Subscript[c, n]) are certain coefficients and x is variable. It's like a polynomial, only more complicated since it has infinitely many terms. Power series are notable because they are easy to work with - much like the polynomials before them. In this notebook, we will explore the convergence of power series and learn how mathematics software can make testing for convergence easy. We will also approximate functions with power series and attempt to understand the effects of truncation.

Syntax and Convergence

As we have seen from previous work, we can express an infinite series in Mathematica as a sum:

Sum[0.5^n, {n,0,Infinity}]

We can also put variables in this definition, and doing so allows us to obtain power series:

Sum[x^n, {n,0,Infinity}]

The above series is a well-known series called a geometric series. This series is known to converge so long as |x| < 1. We can see this if we define a function with := and then plot it:

f[x_]:=Sum[x^n, {n,0,Infinity}]
Plot[f[x],{x,-3,3}]

The values of x for which the series converges is called the interval of convergence.

In general, for a given power series we can find the conditions for it to converge by applying the Absolute Convergence Test and the Ratio Test.

a[n_]:=x^n
f[x_]:=Sum[a[n],{n,0,Infinity}]

In order for it to converge, we need the limit of the sequence |((Subscript[a, n+1])/(Subscript[a, n]))| to converge to a value less than one.

Simplify[Abs[a[n+1]/a[n]]]
Limit[Abs[a[n+1]/a[n]],n-> Infinity]

This leaves us with the |x|<1 condition. Let's try it with something more complicated:

b[n_]:=(-1)^n/(2*n)!*x^(2*n)
g[x_]:=Sum[b[n],{n,0,Infinity}]
g[x]

As before, the test for convergence:

Simplify[Abs[b[n+1]/b[n]]]
Limit[Abs[b[n+1]/b[n]],n-> Infinity]

Since 0<1 no matter our choice of x, this means that this particular series converges for all x.

We can speed up this process with the SumConvergence command:

SumConvergence[a[n],n]
SumConvergence[b[n],n]

If we consider x to be a complex number, these conditions will still apply. The difference is that our interval of convergence will instead become a region of convergence in the complex plane. We can visualize this region with the RegionPlot command:

RegionPlot[SumConvergence[a[n]/.{x-> x+y*I},n],{x,-3,3},{y,-3,3}]
RegionPlot[SumConvergence[b[n]/.{x-> x+y*I},n],{x,-3,3},{y,-3,3}]

Taylor Series and Approximation

We can express a function by a power series. We can compute which series to use explicitly via the Taylor series

f(x)≈((f(a))/(0!))+((f'(a))/(1!))(x-a)+((f''(a))/(2!))(((x-a))^2)+((f'''(a))/(3!))(((x-a))^3)+...

In practice we often truncate this power series to form an approximation of the function. Mathematica has a command called Series which constructs this truncated approximation. Series takes two arguments: first the function to approximate, and then a list of three elements. The first element  is the variable to expand over, the second is the point about which to expand, and the final element is the degree of approximation.

Series[Cos[x],{x,0,2}]

The final term, ((O[x])^3), refers to the error of this approximation. It says that the further x gets away from 0, the greater our error will be. The exponent 3 refers to how fast this error increases: it is proportionate to (x^3). If we want to use the output of Series in our future calculations, we will have to get rid of this term. The way to do this is with the command Normal:

f[x_]=Normal[Series[Cos[x],{x,0,2}]];
Plot[{f[x],Cos[x]},{x,-2 Pi,2 Pi}]

As we can see, the terms we dropped are worth quite a bit. We can gain more insight into how the number of terms affects the approximation with an animated plot:

Manipulate[Plot[Evaluate[{Normal[Series[Cos[x],{x,0,n}]],Cos[x]}],{x,-4Pi,4Pi}, PlotRange-> {-2,2} ],{n,1,20,1}]

We can also observe how changing the point of approximation affects the quality of approximation:

Manipulate[Plot[Evaluate[{Normal[Series[Cos[x],{x,a,n}]],Cos[x]}],{x,-4Pi,4Pi}, PlotRange-> {-2,2} ],{n,1,20,1},{a,-4*Pi,4*Pi}]

The Nth partial sum of a power series is going to be a polynomial of degree at most N-1. This means that a partial sum of a power series is an approximation of a function by a polynomial. If our function is not like a polynomial at all, then we will need a higher degree partial sum in order to have a good approximation.

Exercises

Assignment 1: Examining a Power Series

Investigate the power series (∑_(n=1)^∞)(((n^n)(x^n))/(n! (3^n))). What is its radius of convergence? How quickly does it converge? Your answer should include:

The interval of convergence and radius of convergence.

Point or bar plots of the sequence (((n^n)(x^n))/(n! (3^n))) for at least 3 choices of x, out to at least the 20th term. At least one choice should be inside of the interval of convergence and at least one choice should be outside.

Point or bar plots of the partial sum sequence (∑_(i=1)^n)(((i^i)(x^i))/(i! (3^i))) for at least 3 choices of x, out to at least the 20th term. At least one choice should be inside of the interval of convergence and at least one choice should be outside.

An animated plot of the partial sum approximations, out to at least the 15th degree term.

Assignment 2: Hearing the Effect of Approximation

The goal of this exercise is to approximate the function that converts a 900Hz sawtooth wave into a 900Hz sine wave with Taylor polynomials, and to observe the effects of approximation.  The sawtooth wave we will be working with looks like this:

Plot[SawtoothWave[900*x],{x,-0.01,0.01}]

Mathematica has a command called Play. It is invoked in a similar manner to Plot. It plays the function you give it as a sound. The sawtooth wave we will be working with sounds like this:

Play[SawtoothWave[900*x],{x,0,1},PlayRange-> All]

The sine wave we wish to produce looks like this:

Plot[Sin[2*Pi*900*x],{x,-0.01,0.01}]

And it sounds like this:

Play[Sin[2*Pi*900*x],{x,0,1},PlayRange-> All]

The function that converts from the sawtooth to the sine is sin(2π x). We will compose this function with the sawtooth wave to produce the sine wave like so:

Plot[Sin[2*Pi*SawtoothWave[900*x]],{x,-0.01,0.01}]

Produce several Taylor approximations of sin(2πx) and compose them with the sawtooth wave. Observe how the approximation changes with the degree, both visually (with plots) and aurally (with plays). Your answer should include:

At least four Taylor approximations of sin(2πx) with different degrees.

A plot of all of the Taylor approximations and the true solution sin(2πx) on the same axes over the region [0,1].

A plot of all of the Taylor approximations and the true solution sin(2πx) composed with the sawtooth wave on the same axes over the region [-0.01,0.01].

A comparison of how the sound changes as the the degree of the approximation improves.